package com.baizhi.service.impl;

import com.baizhi.dao.QuestionDao;
import com.baizhi.entity.Question;
import com.baizhi.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class QuestionServiceImpl implements QuestionService {
    @Autowired
    private QuestionDao qd;

    @Override
    @Transactional(readOnly = true)
    public List<Question> selectAll() {
        return qd.selectList(null);
    }

    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public void insert(Question q) {
        qd.insert(q);
    }

    @Override
    public void delete(int id) {
        qd.deleteById(id);
    }

    @Override
    public void update(Question q) {
        qd.updateById(q);
    }


}
